package com.akita.spring.ai.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum BizTypeEnum {

    CHAT("chat", "AI聊天", 1),
    SERVICE("service", "客服", 2),
    PDF("pdf", "PDF问答", 3),
    ;

    private final String type;
    private final String description;
    private final Integer code;

    public static final Map<String, BizTypeEnum> TYPE_MAP = Collections.unmodifiableMap(
            new HashMap<>() {{
                for (BizTypeEnum bizTypeEnum : BizTypeEnum.values()) {
                    put(bizTypeEnum.getType(), bizTypeEnum);
                }
            }}
    );

    public static final Map<Integer, BizTypeEnum> CODE_MAP = Collections.unmodifiableMap(
            new HashMap<>() {{
                for (BizTypeEnum bizTypeEnum : BizTypeEnum.values()) {
                    put(bizTypeEnum.getCode(), bizTypeEnum);
                }
            }}
    );

    public static BizTypeEnum typeOf(String type) {
        return TYPE_MAP.get(type);
    }

    public static BizTypeEnum codeOf(Integer code) {
        return CODE_MAP.get(code);
    }

}
